<template>
  <div>
    <city-header></city-header>
    <city-list :hotCities="hotCities" :cities="cities"></city-list>
  </div>
</template>

<script>
import axios from "axios";
import CityHeader from "./components/Header";
import CityList from "./components/List";
export default {
  name: "City",
  components: {
    "city-header": CityHeader,
    "city-list": CityList
  },
  data() {
    return {
      hotCities: [],
      cities: {}
    };
  },
  mounted() {
    this.getCityInfo();
  },
  methods: {
    getCityInfo() {
      axios.get("/api/city.json").then(this.getCityInfoSuccess);
    },
    getCityInfoSuccess(res) {
      const data = res.data.data;
      this.hotCities = data.hotCities;
      this.cities = data.cities;
    }
  }
};
</script>

<style scoped></style>
